﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RanchBuddy.Core.Domain.Impl;
using StructureMap;

namespace RanchBuddy.Core.DataAccess.Impl
{
    [Pluggable("Default")]
    public class CompanyTypeRepository : ICompanyTypeRepository
    {
        public List<CompanyType> GetCompanyTypes()
        {
            List<CompanyType> result = new List<CompanyType>();
            using (RanchBuddyDataContext dc = ObjectFactory.GetInstance<IConnection>().GetLsContext())
            {
                result = dc.CompanyTypes.OrderBy(t=>t.Name).ToList();
            }
            return result;
        }

        public CompanyType GetCompanyTypeByID(int CompanyTypeID)
        {
            CompanyType result = new CompanyType();
            using (RanchBuddyDataContext dc = ObjectFactory.GetInstance<IConnection>().GetLsContext())
            {
                result = dc.CompanyTypes.Where(t => t.CompanyTypeID == CompanyTypeID).FirstOrDefault();
            }
            return result;
        }
    }
}
